
export abstract class IReference{
    public abstract clear();
}
export class ObjectPool {
    public static instance:ObjectPool = new ObjectPool();
    private map :Map<string,IReference[]>= new Map<string,IReference[]>();
    get(type:typeof IReference ){
        let arr = this.map.get(type.name);
        if (!arr || arr.length == 0) {
            return null;
        }else{
            return arr.pop();
        }
    }
    put(type:typeof IReference,obj:IReference){
        let arr = this.map.get(type.name);
        if (!arr) {
            arr = [];
            this.map.set(type.name,arr);
        }
        arr.push(obj);
    }
}